package cn.fj.game;

import java.awt.Color;
import java.awt.Graphics;

public class Shell extends GameObject {
	double degree;

	public Shell() {
		x = 200;
		y = 200;
		width = 10;
		height = 10;
		speed = 3;
		degree = Math.random() * Math.PI * 2;
	}//这是炮弹的矩形区域

	// 然后就是画出自己的炮弹
	public void draw(Graphics g) {
		Color c = g.getColor();
		g.setColor(Color.yellow);
		g.fillOval((int) x, (int) y, width, height); // 炮弹的填充

		// 让炮弹沿着任意角度去飞
		x += speed * Math.cos(degree);
		y += speed * Math.sin(degree);

		if (x < 0 || x > Constant.GAME_WIDTH - width) {
			degree = Math.PI - degree;
		}
		if (y < 30 || y > Constant.GAME_WIDTH - height) {
			degree = -degree;
		}

		g.setColor(c);
	}
}
